Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use YAML for twitter-log output #260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BigBlueHat
Copy link

First @sixohsix, thanks for building this project! 😺

Second, I found the twitter-log output looked very similar to YAML, but was less auto-magically parse-able with existing tools. This PR includes a change to YAML (just for twitter-log at this point) which can easily be converted into JSON, XML, etc. (using PyYAML, etc) while remaining legible to mere mortals. 😃

It looks essentially like this:

bigbluehat:
 - ID: 524566522782842880
   Date: Tue Oct 21 14:22:59 +0000 2014
   Tweet: |
    RT @darylginn: How I use todo apps:
    1. Write some todos.
    2. Never open the app again.
    3. Delete app.
 - ID: 524011979380654080
   Date: Mon Oct 20 01:39:26 +0000 2014
   Tweet: |
    @CUGreenville how about adding "chaider" to your menu? "chai steeped in cider instead of water." -- @_beechnut

Parsed with PyYAML, it looks like this:

{'bigbluehat': [{'Date': ..., 'Tweet': ...}, ..., ...]}

So Tweets can be referenced in loops, list comprehension, etc.

It would be a simple tweak to output this in two other variations:

  1. each tweet is a distinct YAML document (which would include the screen_name in the document)
  2. make the output an keyed dictionary, rather than a list.

The current format seemed to provide the most flexibility, but let me know if you'd like me to send PRs for the others (or if this is totally not something you want 😉).

Thanks again, @sixohsix

YAML can easily be converted into JSON,
XML, etc. while remaining legible to mere
mortals.
@coveralls
Copy link

Coverage Status

Coverage increased (+2.09%) when pulling 03d46a1 on BigBlueHat:yaml-log-output into 2b533cd on sixohsix:master.

@RouxRC
Copy link
Member

RouxRC commented Dec 24, 2014

This looks fine by me, but this is a paradigm change which I don't feel comfortable like choosing without @sixohsix's approval. Anf if so, it would indeed probably make more sense to include it in all shell tools.

Just a small note: i haven't ran the code, but reading the change it looks to me like it doesn't include anymore the two blank lines between two tweets although the doc at the top still says so.

@hugovk
Copy link
Member

hugovk commented Dec 24, 2014

Perhaps YAML output should be enabled via an option rather then by default, so as not to break existing code.

@oumaima-aarabe
Copy link

oumaima-aarabe commented Aug 26, 2024

to prevent breaking existing code, it might be more prudent to introduce YAML output as an option rather than setting it as the default. This approach would allow users to opt in to the new format while maintaining backward compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants